const jwt = require("jsonwebtoken")        //导入jwt进行用户登录验证
const {Secret_key} = require("../config")  //导入秘钥

const jwtverify = function(req,res,next){
    const token = req.headers.token
    jwt.verify(token,Secret_key,(err,data)=>{
        if (err){
            return res.json({
                errorCode:400,
                msg:"请登录",
                data:null,
                errors:null
            })
        }
        next()
    })
}

module.exports = jwtverify